define(function() {
	return function($compile, $scope) {
		require(
				[ "AppPathDir/order/orderForVisitorProductInfos/support", "AppPathDir/order/orderForVisitorProductInfos/update", "AppPathDir/order/orderForVisitorProductInfos/detail", "PDUtilDir/util",
						"PDUtilDir/tool", "PDUtilDir/slidebar",
						"PDUtilDir/inputSelect", "Date", "DateCN", "css!DateCss"],
				function(Support, UpdateSupport, DetailSupport, Util, Tool, Slidebar, inputSelect) {
                    $scope.cache = {
                        // type : new Array(),
                        // typeMap: new Map(),
                        // status : new Array(),
                        // statuMap: new Map()
                    };
                    $scope.search = {};

					/* 查询 start */
					$scope.searchSupport = {
						run: function(){
							$scope.grid.reload({
                                queryParam : {
                                    model: JSON.stringify($scope.search)
                                }
							})
						}
					};
                    //详情
                    // $scope.detailSupport = DetailSupport($scope, $compile);

                    //修改
                    $scope.agencySupport = UpdateSupport($scope, $compile);

                    //删除
                    $scope.delSupport = {
                        run : function() {
                            var selectRows = $scope.grid.getSelectedRow();
                            if (selectRows.length == 0) {
                                Util.alert('请选择至少一条的数据！');
                                return;
                            }
                            Util.confirm("是否要删除", function() {
                                var ids = new Array();
                                $.each(selectRows, function(index, selectRow) {
                                    ids.push(selectRow.id);
                                });
                                $.ajax({
                                    url : getServer() + "/flea/hclv/productAgency/deteAgencyByIds.htmls",
                                    method : 'post',
                                    data : {
                                        'model' : JSON.stringify(ids)
                                    },
                                    success : function(data) {
                                        if(data.status != 200){
                                            return ;
                                        }
                                        $scope.grid.refresh();
                                        Util.alert(data.message);
                                    }
                                });
                            });
                        }
                    };
                    $scope.grid = Support.init($scope.cache, $scope.delSupport, $scope.agencySupport, $scope.searchSupport);
				})
	}
});